package ch11.d8;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;

public class MyThread extends Thread{
//    static List list=new Vector<>();
    static List list= Collections.synchronizedList(new ArrayList<>());

    public void run() {
       synchronized (list){
           System.out.println(getName()+"进入了同步代码块");
           try {
               Thread.sleep(10000);
           } catch (InterruptedException e) {
               throw new RuntimeException(e);
           }
           System.out.println(getName()+"结束");
       }
    }
}
